<?php

/**
 * contacto actions.
 *
 * @package    catalogo
 * @subpackage contacto
 * @author     Ignacio Di Rocco
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class contactoActions extends sfActions
{

  public function executeNew(sfWebRequest $request)
  {
    $this->form = new ContactoForm();
    
    $this->seccion = Doctrine::getTable('Seccion')->find(10);
  }

  public function executeCreate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod(sfRequest::POST));

    $this->form = new ContactoForm();
    
    $this->seccion = Doctrine::getTable('Seccion')->find(10);

    $this->processForm($request, $this->form);

    $this->setTemplate('new');
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $contacto = $form->save();
      
      $this->getUser()->setFlash('notice', 'El mensaje se ha enviado correctamente.');
      
      $this->redirect('@contacto');
    }
  }
}
